<?php
	include_once "inc/docroot.php";
    include_once PATH."common/base.php";
    $pageTitle = "Home";
    include_once PATH."common/header.php";

    if(!empty($_SESSION['LoggedIn']) && !empty($_SESSION['Username'])):
?>
		<p>You are currently <strong>logged in.</strong></p>
		<p><a href="<?php PATH?>logout.php">Log out</a></p>
<?php
   elseif(!empty($_POST['username']) && !empty($_POST['password'])):
        include_once(PATH."inc/class.users.inc.php");
        $users = new ColoredListsUsers($db);
        if($users->accountLogin()===TRUE):
            echo "Redirecting to <a href=http://localhost/bytefact/index.php>http://localhost/bytefact/index.php</a>";
			header("Location: index.php");
        	exit;
        else:
?>
<h2>Login Failed. <br>Try Again?</h2>
<?php
	endif;
	else:
?>
<form method="post" action="<?php PATH?>login.php" name="loginform" id="loginform">
  <div>
    <input type="text" name="username" id="username" />
    <label for="username">Email</label>
    <br />
    <br />
    <input type="password" name="password" id="password" />
    <label for="password">Password</label>
    <br />
    <br />
    <input type="submit" name="login" id="login" value="Login" class="btn btn--blue btn--m" />
  </div>
</form>
<p><br><a href="<?php PATH?>password.php">Did you forget your password?</a><br></p>
<?php
	endif;
    include_once PATH."common/ads.php";
    include_once PATH."common/close.php";
?>
